package theFrameworks.desa.dao;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;

import theFrameworks.desa.domain.Evento;

@Repository
public class EventoDAOWithJPA implements EventoDAO {

	@PersistenceContext
	protected EntityManager entityManager;

	public EntityManager getEntityManager() {
		return entityManager;
	}

	public void setEntityManager(EntityManager entityManager) {
		this.entityManager = entityManager;
	}

	public void persist(Evento evento) {
		entityManager.persist(evento);

	}

	public void delete(Evento evento) {
		entityManager.createQuery("DELETE FROM Evento e WHERE e.id=:id")
				.setParameter("id", evento.getId()).executeUpdate();

	}

}
